package tetris.features;

import java.util.ArrayList;

import tetris.simulator.State;

public class ColTransitionFeature extends Feature{
  
  @SuppressWarnings("static-access")
  public ArrayList<Double> getFeatureVector(State tetrisState) {
    ArrayList<Double> featureVector = new ArrayList<Double>();
    int transitions = 0;
    MaxColHeightFeature heightFeature = new MaxColHeightFeature();
    int height = heightFeature.getFeatureVector(tetrisState).get(0).intValue();
    for (int i = 0; i < tetrisState.COLS; i++) {
      boolean lastCell = true;
      for (int j = 0; j < height; j++) {
        boolean thisCell = tetrisState.getField()[j][i] > 0;
        if (thisCell != lastCell)
          transitions++;
        lastCell = thisCell;
      }
    }
    featureVector.add(new Double(transitions));
    return featureVector;
  }

}
